import java.util.Random;

public class Task02 {
	public static void main(String[] args) {
		
		for (int i = 0; i < 100; i++) {
			benchmarkRatio(1_000);
			benchmarkRatio(100_000);
			benchmarkRatio(10_000_000);
		}

	}

	private static void benchmarkRatio(int size) {
		int[] a = createArray(size);
		double ratio = 1. * timeManualArrayCopy(a) / timeSystemArrayCopy(a);
		
		System.out.printf("%d: %.5f%n", size, ratio);
	}

	private static long timeSystemArrayCopy(int[] src) {
		int[] dest = new int[src.length];
		long start = System.nanoTime();

		System.arraycopy(src, 0, dest, 0, src.length);

		return System.nanoTime() - start;
	}

	private static long timeManualArrayCopy(int[] src) {
		int[] dest = new int[src.length];
		long start = System.nanoTime();

		for (int i = 0; i < src.length; i++) {
			dest[i] = src[i];
		}

		return System.nanoTime() - start;
	}

	private static int[] createArray(int size) {
		Random rand = new Random();
		int[] a = new int[size];
		for (int i = 0; i < a.length; i++) {
			a[i] = rand.nextInt();
		}
		return a;
	}
}
